package com.ruoyi.web.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.admin.domain.TdmErYiLiaoQiXie;
import com.ruoyi.web.admin.service.ITdmErYiLiaoQiXieService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 二类医疗器械Controller
 * 
 * @author ly
 * @date 2022-03-10
 */
@RestController
@RequestMapping("/admin/TdmErYiLiaoQiXie")
public class TdmErYiLiaoQiXieController extends BaseController
{
    @Autowired
    private ITdmErYiLiaoQiXieService tdmErYiLiaoQiXieService;

    /**
     * 查询二类医疗器械列表
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmErYiLiaoQiXie:list')")
    @GetMapping("/list")
    public TableDataInfo list(TdmErYiLiaoQiXie tdmErYiLiaoQiXie)
    {
        startPage();
        List<TdmErYiLiaoQiXie> list = tdmErYiLiaoQiXieService.selectTdmErYiLiaoQiXieList(tdmErYiLiaoQiXie);
        return getDataTable(list);
    }

    /**
     * 导出二类医疗器械列表
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmErYiLiaoQiXie:export')")
    @Log(title = "二类医疗器械", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TdmErYiLiaoQiXie tdmErYiLiaoQiXie)
    {
        List<TdmErYiLiaoQiXie> list = tdmErYiLiaoQiXieService.selectTdmErYiLiaoQiXieList(tdmErYiLiaoQiXie);
        ExcelUtil<TdmErYiLiaoQiXie> util = new ExcelUtil<TdmErYiLiaoQiXie>(TdmErYiLiaoQiXie.class);
        util.exportExcel(response, list, "二类医疗器械数据");
    }

    /**
     * 获取二类医疗器械详细信息
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmErYiLiaoQiXie:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tdmErYiLiaoQiXieService.selectTdmErYiLiaoQiXieById(id));
    }

    /**
     * 新增二类医疗器械
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmErYiLiaoQiXie:add')")
    @Log(title = "二类医疗器械", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TdmErYiLiaoQiXie tdmErYiLiaoQiXie)
    {
        return toAjax(tdmErYiLiaoQiXieService.insertTdmErYiLiaoQiXie(tdmErYiLiaoQiXie));
    }

    /**
     * 修改二类医疗器械
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmErYiLiaoQiXie:edit')")
    @Log(title = "二类医疗器械", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TdmErYiLiaoQiXie tdmErYiLiaoQiXie)
    {
        return toAjax(tdmErYiLiaoQiXieService.updateTdmErYiLiaoQiXie(tdmErYiLiaoQiXie));
    }

    /**
     * 删除二类医疗器械
     */
//    @PreAuthorize("@ss.hasPermi('admin:TdmErYiLiaoQiXie:remove')")
    @Log(title = "二类医疗器械", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tdmErYiLiaoQiXieService.deleteTdmErYiLiaoQiXieByIds(ids));
    }
}
